<template>
	<!-- 未登录显示 -->
	<view v-if="!userInfo.mobile" class="login-box">
		<image class="logo-img" src="@/static/images/logo2.png" mode=""></image>
		<view class="title">你好，欢迎登录嘉瑟琳</view>
		<view class="btn" @click="handleBtn">手机号快捷登录/注册</view>
		<view class="select-box">
			<checkbox-group @change="checkboxChange">
				<label class="select-label">
					<checkbox :checked="isSelect" style="transform:scale(0.6)" />
					<view class="txt">登录即同意<text>《用户协议》</text>和<text>《隐私政策》</text></view>
				</label>
			</checkbox-group>
		</view>
	</view>
	
	<!-- 登录后显示 -->
	<view v-else class="con-box">
		<image class="top-bg" src="https://build.gzwhir.com/zygzmr202410252905/appImages/my-bg.png" mode=""></image>
		<view class="info-box">
			<view class="info-l">
				<image class="avatar" src="@/static/images/img3.png" mode=""></image>
				<view class="txt-box">
					<view class="txt-box-hd">
						<view class="name">饭饭</view>
						<view class="phone">158****5927</view>
					</view>
					<view class="txt-box-ft" @click="handleCopyTxt">
						<text class="code">分销码: 627598</text>
						<image class="copy" src="@/static/images/copy.png" mode=""></image>
					</view>
				</view>
			</view>
			<view class="info-r" @click="clickJump('/pages/my/info')">编辑资料</view>
		</view>
		
		<view class="list-box">
			<view class="list1">
				<view class="item" @click="clickJump('/pages/my/info')">
					<image class="img" src="@/static/images/my-icon1.png" mode=""></image>
					<view class="txt">我的资料</view>
				</view>
				<view class="item" @click="clickJump('/pages/my/record')">
					<image class="img" src="@/static/images/my-icon2.png" mode=""></image>
					<view class="txt">问卷记录</view>
				</view>
				<view class="item" @click="clickJump('/pages/my/sale')">
					<image class="img" src="@/static/images/my-icon3.png" mode=""></image>
					<view class="txt">我的分销</view>
				</view>
			</view>
			<view class="list2">
				<view class="item" @click="clickJump('/pages/my/contactUs')">
					<image class="imgL" src="@/static/images/my-icon4.png" mode=""></image>
					<view class="txt">联系客服</view>
					<image class="imgR" src="@/static/images/allow-right.png" mode=""></image>
				</view>
				<view class="item" @click="openExitPopup">
					<image class="imgL" src="@/static/images/my-icon5.png" mode=""></image>
					<view class="txt">退出</view>
					<image class="imgR" src="@/static/images/allow-right.png" mode=""></image>
				</view>
			</view>
		</view>
	</view>
	
	<uni-popup ref="popupRef" type="center">
		<view class="popup-box">
			<view class="title">确定退出登录吗？</view>
			<view class="popup-ft">
				<view class="popup-ft-l" @click="handlePopupClose">取消</view>
				<view class="popup-ft-r" @click="handlePopupBtn">确定</view>
			</view>
		</view>
	</uni-popup>
</template>

<script setup>
	import { ref } from 'vue'
	
	let userInfo = ref({})
	
	let isSelect = ref(false)
	let checkboxChange = () => {
		isSelect.value = !isSelect.value
	}
	let handleBtn = () => {
		if(isSelect.value){
			userInfo.value = {
				mobile: 13188888888
			}
		}else{
			uni.showToast({
			    title: '请勾选',
			    icon: 'none',
			    duration: 1000
			});
		}
	}
	
	let handleCopyTxt = () => {
		uni.setClipboardData({
			data: '627598',
			success: function () {
				// console.log('success');
			}
		});
	}
	let clickJump = (url) => {
		uni.navigateTo({
			url: url
		})
	}
	let popupRef = ref(null)
	// 点击退出
	let openExitPopup = () => {
		popupRef.value.open()
	}
	let handlePopupClose = () => {
		popupRef.value.close()
	}
	let handlePopupBtn = () => {
		popupRef.value.close()
		userInfo.value = {}
	}
	
	
</script>

<style lang="scss">
.con-box{
	position: relative;
	.top-bg{
		position: absolute;
		left: 0;
		top: 0;
		width: 750rpx;
		height: 500rpx;
		z-index: -1;
	}
	
	.info-box{
		display: flex;
		align-items: center;
		justify-content: space-between;
		padding: 60rpx 40rpx;
		
		.info-l{
			display: flex;
			align-items: center;
			
			.avatar{
				width: 120rpx;
				height: 120rpx;
			}
			.txt-box{
				margin-left: 30rpx;
				.txt-box-hd{
					display: flex;
					align-items: center;
					.name{
						font-size: 28rpx;
						color: #333;
						font-weight: bold;
						margin-right: 20rpx;
					}
					.phone{
						font-size: 24rpx;
						color: #333;
					}
				}
				.txt-box-ft{
					.code{
						font-size: 20rpx;
						color: #888;
					}
					.copy{
						width: 20rpx;
						height: 20rpx;
						margin-left: 10rpx;
					}
				}
			}
		}
		.info-r{
			width: 180rpx;
			height: 64rpx;
			border-radius: 60px;
			background: #aae9f2;
			display: flex;
			align-items: center;
			justify-content: center;
			font-size: 24rpx;
			color: #333;
			font-weight: 500;
		}
	}
	
	.list-box{
		border-radius: 50rpx 50rpx 0 0;
		background: linear-gradient(to bottom, #fbfbfb, #f5f5f5);
		position: relative;
		padding-top: 200rpx;
		margin-top: 60rpx;
		
		.list1{
			display: flex;
			align-items: center;
			justify-content: space-around;
			position: absolute;
			left: 0;
			top: -70rpx;
			width: 100%;
			
			.item{
				width: 200rpx;
				height: 200rpx;
				border: 2px solid #fff;
				border-radius: 20rpx;
				background: linear-gradient(45deg, #fff 10%, #ebebeb);
				display: flex;
				align-items: center;
				justify-content: center;
				flex-direction: column;
				
				.img{
					width: 56rpx;
					height: 56rpx;
				}
				.txt{
					font-size: 28rpx;
					color: #333;
					margin-top: 10rpx;
				}
			}
		}
		.list2{
			background: #fff;
			border-radius: 20rpx;
			padding: 40rpx;
			.item{
				display: flex;
				align-items: center;
				border-bottom: 1px solid #e1e1e1;
				padding-bottom: 40rpx;
				margin-bottom: 40rpx;
				
				&:last-child{
					border-bottom: none;
					padding-bottom: 0rpx;
					margin-bottom: 0rpx;
				}
				
				.imgL{
					width: 30rpx;
					height: 30rpx;
				}
				.txt{
					font-size: 28rpx;
					color: #333;
					margin-left: 20rpx;
				}
				.imgR{
					width: 11rpx;
					height: 21rpx;
					margin-left: auto;
				}
			}
		}
	}
}

.popup-box{
	width: 480rpx;
	background: #fff;
	border-radius: 15rpx;
	
	.title{
		font-size: 28rpx;
		color: #333;
		text-align: center;
		padding: 70rpx 0;
	}
	.popup-ft{
		display: flex;
		align-items: center;
		justify-content: space-between;
		border-top: 1px solid #e5e5e5;
		
		.popup-ft-l{
			width: 49%;
			height: 100rpx;
			display: flex;
			align-items: center;
			justify-content: center;
			color: #888;
			font-size: 28rpx;
			border-right: 1px solid #e5e5e5;
		}
		.popup-ft-r{
			width: 49%;
			height: 100rpx;
			display: flex;
			align-items: center;
			justify-content: center;
			color: #333;
			font-size: 28rpx;
		}
	}
}

.login-box{
	background: #fff;
	border-radius: 20rpx;
	margin: 50rpx 40rpx auto;
	text-align: center;
	padding-bottom: 100rpx;
	
	.logo-img{
		width: 186rpx;
		height: 36rpx;
		padding-top: 100rpx;
		padding-bottom: 50rpx;
	}
	.title{
		font-size: 40rpx;
		color: #333;
		font-weight: bold;
	}
	.btn{
		width: 84%;
		height: 90rpx;
		border-radius: 90px;
		background: #aae9f2;
		display: flex;
		align-items: center;
		justify-content: center;
		font-size: 28rpx;
		color: #333;
		font-weight: 500;
		margin: 140rpx auto 0;
	}
	.select-box{
		margin-top: 30rpx;
		
		.select-label{
			display: flex;
			align-items: center;
			justify-content: center;
			
			.txt{
				font-size: 24rpx;
				color: #888;
				text{
					color: #333;
				}
			}
		}
	}
}

</style>
